﻿using System;

namespace ExcelConfig.StoreAPI.ec_eng
{
    using SanlieHash.Fast;
    using SanlieHash;
    internal class ec_202508 : IEC
    {
        public string Encrypt(string msg)
        {
            var pass = AppConfig.Text("验证密码");
            var passkey = pass.Split('-')[0];
            var p0 = FastGuoMi.EncryptSM4(pass, FastGuoMi.GetSM3(msg));
            var p1 = FastGuoMi.GetSM3(p0);
            var p2 = FastHash.GetMD6(p0 + pass);
            var key = FastGuoMi.EncryptSM4(FastEncode.Base64Encode(FastEncode.EncodeMorse(p2)), FastAES.Encrypt(pass, p1));
            var msg1 = FastGuoMi.EncryptSM4(msg, p2);
            var m1 = FastEncode.Base64Encode(FastEncode.EncodeMorse(p1));
            var msg_out = passkey + "#" + FastEncode.EncodeUInt((uint)m1.Length) + m1 + FastEncode.EncodeUInt((uint)key.Length) + key + FastEncode.EncodeUInt((uint)msg1.Length) + msg1;
            return msg_out;
        }
    }
}
